<template>
<div>

<div class="apply_title"><i></i>申请单位信息</div>
 
<mt-field label="申请单位" class="text-right" :class="compony.unit.error?'errorcolor':''" placeholder="请输入申请单位"   v-model="compony.unit.vale"></mt-field>
<mt-cell title="单位类型" is-link :class="compony.componystyle.error?'errorcolor':''"  @click.native="componystylefun"  :value="compony.componystyle.vale" ></mt-cell>
<mt-field label="法定代表人/负责人" :class="compony.bossshow.error?'errorcolor':''" placeholder="请输入法定代表人/负责人" v-if="compony.bossshow.show" class="text-right"  v-model="compony.bossname.vale"></mt-field>
<mt-field label="注册地址" :class="compony.add1.error?'errorcolor':''" placeholder="请输入注册地址" class="text-right" v-if="compony.bossshow.show"  v-model="compony.add1.vale"></mt-field>
<mt-field label="办公地址" :class="compony.add2.error?'errorcolor':''" placeholder="请输入办公地址" class="text-right"  v-model="compony.add2.vale"></mt-field>
<mt-field label="单位职务" :class="compony.post.error?'errorcolor':''" placeholder="请输入单位职务" class="text-right"  v-model="compony.post.vale"></mt-field>
<mt-field label="经办人" :class="compony.agent1.error?'errorcolor':''" placeholder="请输入经办人" class="text-right"  v-model="compony.agent1.vale"></mt-field>
<mt-field label="经办人电话" :class="compony.agent2.error?'errorcolor':''" placeholder="请输入经办人电话" class="text-right"  v-model="compony.agent2.vale"></mt-field>
<mt-field label="经办人邮箱" :class="compony.agent3.error?'errorcolor':''" placeholder="请输入经办人邮箱" class="text-right"  v-model="compony.agent3.vale"></mt-field>
<div class="am-whitespace ws15px"></div>
<div class="inputbtn"><mt-button type="primary" @click="gopage" style="width:100%;">下一步</mt-button></div>
<mt-actionsheet  :actions="compony.componystyle.select"  v-model="compony.componystyle.actionsheet"></mt-actionsheet>

</div>
</template>
<script>
export default {
    data(){
        return{
             errorr:false,
             
            compony:{
                bossshow:{
                    vale:"",
                    show:true,
                    error:false
                },
                unit:{
                    vale:"",
                    error:false
                },
                bossname:{
                    vale:"",
                    error:false
                },
                add1:{
                    vale:"",
                    error:false
                },
                add2:{
                    vale:"",
                    error:false
                },
                post:{
                    vale:"",
                    error:false
                },
                agent1:{
                    vale:"",
                    error:false
                },
                agent2:{
                    vale:"",
                    error:false
                },
                agent3:{
                    vale:"",
                    error:false
                },
                componystyle:{
                error:false,
                actionsheet:false,
                vale:"输入单位类型",
                select:[{
                    "name":"政府机关",
                    "method":()=>{
                        this.compony.componystyle.vale="政府机关";
                        this.compony.bossshow.show=false;
                        this.compony.bossshow.vale="政府机关";
                    }
                },{
                    "name":"事业单位",
                    "method":()=>{
                        this.compony.componystyle.vale="事业单位";
                        this.compony.bossshow.show=false;
                        this.compony.bossshow.vale="事业单位";

                    }
                },{
                    "name":"企业",
                    "method":()=>{
                        this.compony.componystyle.vale="企业";
                        this.compony.bossshow.show=true;
                        this.compony.bossshow.vale="企业";
                    }
                },{
                    "name":"其他",
                    "method":()=>{
                        this.compony.componystyle.vale="其他";
                        this.compony.bossshow.show=true;
                        this.compony.bossshow.vale="其他";
                    }
                }]
            }
            }

        }
    },
    methods:{
      componystylefun(){
          this.compony.componystyle.actionsheet=true;
      },   
        gopage(){
                let form={};
                let that=this;
                form = JSON.parse(JSON.stringify(that.compony));
                if(that.compony.bossshow.show===false){//企业
                    delete form.bossname;
                    delete form.add1;
                }
                that.errorr = false;
                debugger
                Object.keys(form).map(item=>{
                    if(!form[item].vale||form[item].vale===true||form[item].vale=="输入单位类型"){
                         
                                if(!that.errorr){
                                    that.toast({
                                        message:'信息未填写完整！',
                                        duration: 3000
                                    });
                                }
                                that.compony[item].error = true;
                                that.errorr = true;
                            }else{
                                that.compony[item].error = false;
                            }
                    });

            if(!that.errorr){
                   let params ={
                        head:{mscode: "RC007"},
                        content:{
                            a0100:that.utils.getInfo().name
                        }
                    }
                    params.head = JSON.stringify(params.head );
                    params.content = JSON.stringify(params.content );
                    params = that.qs.stringify(params);
                     that.$router.push({
                                path:'/applycondition'
                      });
                    //  that.$api.commonFormBodyPost('/AppAddzsServlet',params).then(res=>{
                    //     if(res.head && res.head.ret == '1'){
                    //         that.$toast({
                    //             message:'保存成功！',
                    //             duration: 3000
                    //         });
                    //         that.$router.push({
                    //             path:'/applicantInf'
                    //         })
                    //     }else{
                    //         that.$toast({
                    //             message:res.head && res.head.retmsg,
                    //             duration: 3000
                    //         });
                    //     }
                    // })

            }

        }
    }
}
</script>
<style lang="less">
.errorcolor .mint-cell-text{ color:#ff0000;}
.text-right .mint-cell-wrapper .mint-cell-value .mint-field-core{
         text-align: right;
}
.apply_title{height: .4rem;line-height: .4rem; background-color: #ffffff;
i{width: 0;height: 0;border-style: solid;border-width: .1rem 0 .08rem .08rem;border-color: transparent transparent transparent #007bff; float: left; margin: .1rem .1rem 0 .2rem } 
}
.country-title{ margin:-.05rem .08rem .08rem;
.tip{ font-weight: bold; color:#26a2ff;}
}
.country-content{ background-color: #ffffff; padding: .1rem 0 .05rem .1rem;}
.inputbtn{ padding:.2rem .1rem .1rem}
.titlelong .mint-cell-wrapper .mint-cell-title{width: 2rem}
.apply_select .mint-actionsheet-list{ overflow-y: auto; height: 3rem;}
</style>